OpenTelemetry Propagation Utils
A collection of propagation utils for opentelemetry.
Install
npm install --save @opentelemetry/propagation-utils
Usage
PubSub
To make sure each message handled by pubsub creates a new process
span, and propagates to any internal operation, do as follow:
import { pubsubPropagation } from '@opentelemetry/propagation-utils';
import { Span, propagation, trace, Context } from '@opentelemetry/api';
const patch = (message: Message[], rootSpan: Span) => {
const tracer = trace.getTracer('my-tracer');
pubsubPropagation.patchArrayForProcessSpans(messages, tracer);
pubsubPropagation.patchMessagesArrayToStartProcessSpans<Message>({
messages,
tracer,
parentSpan: rootSpan,
messageToSpanDetails: (message) => ({
attributes: { ... },
name: 'some-name',
parentContext: propagation.extract(....) as Context
}),
});
}
Useful links
License
Apache 2.0 - See LICENSE for more information.